using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace MONA.Modules.Marketing.BLL
{
    public partial class Service
    {
        #region Private members.

        protected int _ID;
        protected string _Name = string.Empty;
        protected string _Description = string.Empty;
        protected int _PriorityID;
        protected int _StatusID;
        protected int _CustomerID;
        protected int _CustomerProjectManagerID;
        protected int _ProjectManagerID;
        protected int _AssignedToUserID;
        protected int _NextActionID;
        protected int _ServiceTypeID;
        protected int _ServiceHistoryID;
        protected bool _IsDeleted;
        protected bool _IsClosed;
        protected decimal _Price;
        protected decimal _MinPrice;
        protected decimal _MaxPrice;
        protected string _Summary = string.Empty;
        protected DateTime _FromDate;
        protected DateTime _ToDate;
        protected DateTime _CreatedDate;
        protected int _CreatedByUserID;
        protected int _LastUpdatedByUserID;
        protected DateTime _LastUpdatedDate;

        #endregion

        //---------------------------------------------------------------------------------------------

        #region Properties.

        public int ID
        {
            set { this._ID = value; }
            get { return this._ID; }
        }

        public string Name
        {
            set { this._Name = value; }
            get { return this._Name; }
        }

        public string Description
        {
            set { this._Description = value; }
            get { return this._Description; }
        }

        public int PriorityID
        {
            set { this._PriorityID = value; }
            get { return this._PriorityID; }
        }

        public int StatusID
        {
            set { this._StatusID = value; }
            get { return this._StatusID; }
        }

        public int CustomerID
        {
            set { this._CustomerID = value; }
            get { return this._CustomerID; }
        }

        public int CustomerProjectManagerID
        {
            set { this._CustomerProjectManagerID = value; }
            get { return this._CustomerProjectManagerID; }
        }

        public int ProjectManagerID
        {
            set { this._ProjectManagerID = value; }
            get { return this._ProjectManagerID; }
        }

        public int AssignedToUserID
        {
            set { this._AssignedToUserID = value; }
            get { return this._AssignedToUserID; }
        }

        public int NextActionID
        {
            set { this._NextActionID = value; }
            get { return this._NextActionID; }
        }

        public int ServiceTypeID
        {
            set { this._ServiceTypeID = value; }
            get { return this._ServiceTypeID; }
        }

        public int ServiceHistoryID
        {
            set { this._ServiceHistoryID = value; }
            get { return this._ServiceHistoryID; }
        }

        public bool IsDeleted
        {
            set { this._IsDeleted = value; }
            get { return this._IsDeleted; }
        }

        public bool IsClosed
        {
            set { this._IsClosed = value; }
            get { return this._IsClosed; }
        }

        public decimal Price
        {
            set { this._Price = value; }
            get { return this._Price; }
        }

        public decimal MinPrice
        {
            set { this._MinPrice = value; }
            get { return this._MinPrice; }
        }

        public decimal MaxPrice
        {
            set { this._MaxPrice = value; }
            get { return this._MaxPrice; }
        }

        public string Summary
        {
            set { this._Summary = value; }
            get { return this._Summary; }
        }

        public DateTime FromDate
        {
            set { this._FromDate = value; }
            get { return this._FromDate; }
        }

        public DateTime ToDate
        {
            set { this._ToDate = value; }
            get { return this._ToDate; }
        }

        public DateTime CreatedDate
        {
            set { this._CreatedDate = value; }
            get { return this._CreatedDate; }
        }

        public int CreatedByUserID
        {
            set { this._CreatedByUserID = value; }
            get { return this._CreatedByUserID; }
        }

        public int LastUpdatedByUserID
        {
            set { this._LastUpdatedByUserID = value; }
            get { return this._LastUpdatedByUserID; }
        }

        public DateTime LastUpdatedDate
        {
            set { this._LastUpdatedDate = value; }
            get { return this._LastUpdatedDate; }
        }


        #endregion

        //---------------------------------------------------------------------------------------------

        #region Select methods.

        public static Service Load(int iD)
        {
            string spName = "[dbo].p_MARKETING_Service_Load";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ID", SqlDbType.Int, iD);
            Service entity = null;
            IDataReader reader = db.ExecuteReader(dbCommand);
            if (reader.Read())
            {
                entity = new Service();
                if (!reader.IsDBNull(reader.GetOrdinal("ID"))) entity.ID = reader.GetInt32(reader.GetOrdinal("ID"));
                if (!reader.IsDBNull(reader.GetOrdinal("Name"))) entity.Name = reader.GetString(reader.GetOrdinal("Name"));
                if (!reader.IsDBNull(reader.GetOrdinal("Description"))) entity.Description = reader.GetString(reader.GetOrdinal("Description"));
                if (!reader.IsDBNull(reader.GetOrdinal("PriorityID"))) entity.PriorityID = reader.GetInt32(reader.GetOrdinal("PriorityID"));
                if (!reader.IsDBNull(reader.GetOrdinal("StatusID"))) entity.StatusID = reader.GetInt32(reader.GetOrdinal("StatusID"));
                if (!reader.IsDBNull(reader.GetOrdinal("CustomerID"))) entity.CustomerID = reader.GetInt32(reader.GetOrdinal("CustomerID"));
                if (!reader.IsDBNull(reader.GetOrdinal("CustomerProjectManagerID"))) entity.CustomerProjectManagerID = reader.GetInt32(reader.GetOrdinal("CustomerProjectManagerID"));
                if (!reader.IsDBNull(reader.GetOrdinal("ProjectManagerID"))) entity.ProjectManagerID = reader.GetInt32(reader.GetOrdinal("ProjectManagerID"));
                if (!reader.IsDBNull(reader.GetOrdinal("AssignedToUserID"))) entity.AssignedToUserID = reader.GetInt32(reader.GetOrdinal("AssignedToUserID"));
                if (!reader.IsDBNull(reader.GetOrdinal("NextActionID"))) entity.NextActionID = reader.GetInt32(reader.GetOrdinal("NextActionID"));
                if (!reader.IsDBNull(reader.GetOrdinal("ServiceTypeID"))) entity.ServiceTypeID = reader.GetInt32(reader.GetOrdinal("ServiceTypeID"));
                if (!reader.IsDBNull(reader.GetOrdinal("ServiceHistoryID"))) entity.ServiceHistoryID = reader.GetInt32(reader.GetOrdinal("ServiceHistoryID"));
                if (!reader.IsDBNull(reader.GetOrdinal("IsDeleted"))) entity.IsDeleted = reader.GetBoolean(reader.GetOrdinal("IsDeleted"));
                if (!reader.IsDBNull(reader.GetOrdinal("IsClosed"))) entity.IsClosed = reader.GetBoolean(reader.GetOrdinal("IsClosed"));
                if (!reader.IsDBNull(reader.GetOrdinal("Price"))) entity.Price = reader.GetDecimal(reader.GetOrdinal("Price"));
                if (!reader.IsDBNull(reader.GetOrdinal("MinPrice"))) entity.MinPrice = reader.GetDecimal(reader.GetOrdinal("MinPrice"));
                if (!reader.IsDBNull(reader.GetOrdinal("MaxPrice"))) entity.MaxPrice = reader.GetDecimal(reader.GetOrdinal("MaxPrice"));
                if (!reader.IsDBNull(reader.GetOrdinal("Summary"))) entity.Summary = reader.GetString(reader.GetOrdinal("Summary"));
                if (!reader.IsDBNull(reader.GetOrdinal("FromDate"))) entity.FromDate = reader.GetDateTime(reader.GetOrdinal("FromDate"));
                if (!reader.IsDBNull(reader.GetOrdinal("ToDate"))) entity.ToDate = reader.GetDateTime(reader.GetOrdinal("ToDate"));
                if (!reader.IsDBNull(reader.GetOrdinal("CreatedDate"))) entity.CreatedDate = reader.GetDateTime(reader.GetOrdinal("CreatedDate"));
                if (!reader.IsDBNull(reader.GetOrdinal("CreatedByUserID"))) entity.CreatedByUserID = reader.GetInt32(reader.GetOrdinal("CreatedByUserID"));
                if (!reader.IsDBNull(reader.GetOrdinal("LastUpdatedByUserID"))) entity.LastUpdatedByUserID = reader.GetInt32(reader.GetOrdinal("LastUpdatedByUserID"));
                if (!reader.IsDBNull(reader.GetOrdinal("LastUpdatedDate"))) entity.LastUpdatedDate = reader.GetDateTime(reader.GetOrdinal("LastUpdatedDate"));
            }
            reader.Close();
            dbCommand.Connection.Close();

            return entity;
        }

        //---------------------------------------------------------------------------------------------

        public static DataSet SelectBy_ServiceHistoryID(int serviceHistoryID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_ServiceHistoryID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ServiceHistoryID", SqlDbType.Int, serviceHistoryID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------
        public static DataSet SelectBy_ServiceTypeID(int serviceTypeID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_ServiceTypeID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ServiceTypeID", SqlDbType.Int, serviceTypeID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------
        public static DataSet SelectBy_StatusID(int statusID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_StatusID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@StatusID", SqlDbType.Int, statusID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------
        public static DataSet SelectBy_PriorityID(int priorityID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_PriorityID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@PriorityID", SqlDbType.Int, priorityID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------
        public static DataSet SelectBy_CustomerID(int customerID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_CustomerID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@CustomerID", SqlDbType.Int, customerID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------
        public static DataSet SelectBy_ProjectManagerID(int projectManagerID)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectBy_ProjectManagerID";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ProjectManagerID", SqlDbType.Int, projectManagerID);

            return db.ExecuteDataSet(dbCommand);
        }
        //---------------------------------------------------------------------------------------------

        public static DataSet SelectAll()
        {
            string spName = "[dbo].p_MARKETING_Service_SelectAll";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);


            return db.ExecuteDataSet(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        public static IDataReader SelectReaderAll()
        {
            string spName = "[dbo].p_MARKETING_Service_SelectAll";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);


            return db.ExecuteReader(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        public static DataSet SelectDynamic(string whereCondition, string orderByExpression)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectDynamic";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@WhereCondition", SqlDbType.NVarChar, whereCondition);
            db.AddInParameter(dbCommand, "@OrderByExpression", SqlDbType.NVarChar, orderByExpression);

            return db.ExecuteDataSet(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        public static IDataReader SelectReaderDynamic(string whereCondition, string orderByExpression)
        {
            string spName = "[dbo].p_MARKETING_Service_SelectDynamic";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@WhereCondition", SqlDbType.NVarChar, whereCondition);
            db.AddInParameter(dbCommand, "@OrderByExpression", SqlDbType.NVarChar, orderByExpression);

            return db.ExecuteReader(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------------------------

        #region Insert methods.

        public static int Insert(string name, string description, int priorityID, int statusID, int customerID, int customerProjectManagerID, int projectManagerID, int assignedToUserID, int nextActionID, int serviceTypeID, int serviceHistoryID, bool isDeleted, bool isClosed, decimal price, decimal minPrice, decimal maxPrice, string summary, DateTime fromDate, DateTime toDate, DateTime createdDate, int createdByUserID, int lastUpdatedByUserID, DateTime lastUpdatedDate)
        {
            Service entity = new Service();
            entity.Name = name;
            entity.Description = description;
            entity.PriorityID = priorityID;
            entity.StatusID = statusID;
            entity.CustomerID = customerID;
            entity.CustomerProjectManagerID = customerProjectManagerID;
            entity.ProjectManagerID = projectManagerID;
            entity.AssignedToUserID = assignedToUserID;
            entity.NextActionID = nextActionID;
            entity.ServiceTypeID = serviceTypeID;
            entity.ServiceHistoryID = serviceHistoryID;
            entity.IsDeleted = isDeleted;
            entity.IsClosed = isClosed;
            entity.Price = price;
            entity.MinPrice = minPrice;
            entity.MaxPrice = maxPrice;
            entity.Summary = summary;
            entity.FromDate = fromDate;
            entity.ToDate = toDate;
            entity.CreatedDate = createdDate;
            entity.CreatedByUserID = createdByUserID;
            entity.LastUpdatedByUserID = lastUpdatedByUserID;
            entity.LastUpdatedDate = lastUpdatedDate;
            return entity.Insert();
        }

        public int Insert()
        {
            return this.Insert(null);
        }

        //---------------------------------------------------------------------------------------------

        public int Insert(SqlTransaction transaction)
        {
            string spName = "[dbo].p_MARKETING_Service_Insert";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddOutParameter(dbCommand, "@ID", SqlDbType.Int, 4);
            db.AddInParameter(dbCommand, "@Name", SqlDbType.NVarChar, this._Name);
            db.AddInParameter(dbCommand, "@Description", SqlDbType.NVarChar, this._Description);
            db.AddInParameter(dbCommand, "@PriorityID", SqlDbType.Int, this._PriorityID);
            db.AddInParameter(dbCommand, "@StatusID", SqlDbType.Int, this._StatusID);
            db.AddInParameter(dbCommand, "@CustomerID", SqlDbType.Int, this._CustomerID);
            db.AddInParameter(dbCommand, "@CustomerProjectManagerID", SqlDbType.Int, this._CustomerProjectManagerID);
            db.AddInParameter(dbCommand, "@ProjectManagerID", SqlDbType.Int, this._ProjectManagerID);
            db.AddInParameter(dbCommand, "@AssignedToUserID", SqlDbType.Int, this._AssignedToUserID);
            db.AddInParameter(dbCommand, "@NextActionID", SqlDbType.Int, this._NextActionID);
            db.AddInParameter(dbCommand, "@ServiceTypeID", SqlDbType.Int, this._ServiceTypeID);
            db.AddInParameter(dbCommand, "@ServiceHistoryID", SqlDbType.Int, this._ServiceHistoryID);
            db.AddInParameter(dbCommand, "@IsDeleted", SqlDbType.Bit, this._IsDeleted);
            db.AddInParameter(dbCommand, "@IsClosed", SqlDbType.Bit, this._IsClosed);
            db.AddInParameter(dbCommand, "@Price", SqlDbType.Money, this._Price);
            db.AddInParameter(dbCommand, "@MinPrice", SqlDbType.Money, this._MinPrice);
            db.AddInParameter(dbCommand, "@MaxPrice", SqlDbType.Money, this._MaxPrice);
            db.AddInParameter(dbCommand, "@Summary", SqlDbType.NVarChar, this._Summary);
            db.AddInParameter(dbCommand, "@FromDate", SqlDbType.DateTime, this._FromDate);
            db.AddInParameter(dbCommand, "@ToDate", SqlDbType.DateTime, this._ToDate);
            db.AddInParameter(dbCommand, "@CreatedDate", SqlDbType.DateTime, this._CreatedDate);
            db.AddInParameter(dbCommand, "@CreatedByUserID", SqlDbType.Int, this._CreatedByUserID);
            db.AddInParameter(dbCommand, "@LastUpdatedByUserID", SqlDbType.Int, this._LastUpdatedByUserID);
            db.AddInParameter(dbCommand, "@LastUpdatedDate", SqlDbType.DateTime, this._LastUpdatedDate);

            if (transaction != null)
            {
                db.ExecuteNonQuery(dbCommand, transaction);
                this._ID = (int)db.GetParameterValue(dbCommand, "@ID");
                return this._ID;
            }
            else
            {
                db.ExecuteNonQuery(dbCommand);
                this._ID = (int)db.GetParameterValue(dbCommand, "@ID");
                return this._ID;
            }
        }

        //---------------------------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------------------------

        #region Update methods.

        public static int Update(int iD, string name, string description, int priorityID, int statusID, int customerID, int customerProjectManagerID, int projectManagerID, int assignedToUserID, int nextActionID, int serviceTypeID, int serviceHistoryID, bool isDeleted, bool isClosed, decimal price, decimal minPrice, decimal maxPrice, string summary, DateTime fromDate, DateTime toDate, DateTime createdDate, int createdByUserID, int lastUpdatedByUserID, DateTime lastUpdatedDate)
        {
            Service entity = new Service();
            entity.ID = iD;
            entity.Name = name;
            entity.Description = description;
            entity.PriorityID = priorityID;
            entity.StatusID = statusID;
            entity.CustomerID = customerID;
            entity.CustomerProjectManagerID = customerProjectManagerID;
            entity.ProjectManagerID = projectManagerID;
            entity.AssignedToUserID = assignedToUserID;
            entity.NextActionID = nextActionID;
            entity.ServiceTypeID = serviceTypeID;
            entity.ServiceHistoryID = serviceHistoryID;
            entity.IsDeleted = isDeleted;
            entity.IsClosed = isClosed;
            entity.Price = price;
            entity.MinPrice = minPrice;
            entity.MaxPrice = maxPrice;
            entity.Summary = summary;
            entity.FromDate = fromDate;
            entity.ToDate = toDate;
            entity.CreatedDate = createdDate;
            entity.CreatedByUserID = createdByUserID;
            entity.LastUpdatedByUserID = lastUpdatedByUserID;
            entity.LastUpdatedDate = lastUpdatedDate;
            return entity.Update();
        }

        public int Update()
        {
            return this.Update(null);
        }

        //---------------------------------------------------------------------------------------------

        public int Update(SqlTransaction transaction)
        {
            string spName = "[dbo].p_MARKETING_Service_Update";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ID", SqlDbType.Int, this._ID);
            db.AddInParameter(dbCommand, "@Name", SqlDbType.NVarChar, this._Name);
            db.AddInParameter(dbCommand, "@Description", SqlDbType.NVarChar, this._Description);
            db.AddInParameter(dbCommand, "@PriorityID", SqlDbType.Int, this._PriorityID);
            db.AddInParameter(dbCommand, "@StatusID", SqlDbType.Int, this._StatusID);
            db.AddInParameter(dbCommand, "@CustomerID", SqlDbType.Int, this._CustomerID);
            db.AddInParameter(dbCommand, "@CustomerProjectManagerID", SqlDbType.Int, this._CustomerProjectManagerID);
            db.AddInParameter(dbCommand, "@ProjectManagerID", SqlDbType.Int, this._ProjectManagerID);
            db.AddInParameter(dbCommand, "@AssignedToUserID", SqlDbType.Int, this._AssignedToUserID);
            db.AddInParameter(dbCommand, "@NextActionID", SqlDbType.Int, this._NextActionID);
            db.AddInParameter(dbCommand, "@ServiceTypeID", SqlDbType.Int, this._ServiceTypeID);
            db.AddInParameter(dbCommand, "@ServiceHistoryID", SqlDbType.Int, this._ServiceHistoryID);
            db.AddInParameter(dbCommand, "@IsDeleted", SqlDbType.Bit, this._IsDeleted);
            db.AddInParameter(dbCommand, "@IsClosed", SqlDbType.Bit, this._IsClosed);
            db.AddInParameter(dbCommand, "@Price", SqlDbType.Money, this._Price);
            db.AddInParameter(dbCommand, "@MinPrice", SqlDbType.Money, this._MinPrice);
            db.AddInParameter(dbCommand, "@MaxPrice", SqlDbType.Money, this._MaxPrice);
            db.AddInParameter(dbCommand, "@Summary", SqlDbType.NVarChar, this._Summary);
            db.AddInParameter(dbCommand, "@FromDate", SqlDbType.DateTime, this._FromDate);
            db.AddInParameter(dbCommand, "@ToDate", SqlDbType.DateTime, this._ToDate);
            db.AddInParameter(dbCommand, "@CreatedDate", SqlDbType.DateTime, this._CreatedDate);
            db.AddInParameter(dbCommand, "@CreatedByUserID", SqlDbType.Int, this._CreatedByUserID);
            db.AddInParameter(dbCommand, "@LastUpdatedByUserID", SqlDbType.Int, this._LastUpdatedByUserID);
            db.AddInParameter(dbCommand, "@LastUpdatedDate", SqlDbType.DateTime, this._LastUpdatedDate);

            if (transaction != null)
                return db.ExecuteNonQuery(dbCommand, transaction);
            else
                return db.ExecuteNonQuery(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------------------------

        #region Delete methods.

        public static int Delete(int iD)
        {
            Service entity = new Service();
            entity.ID = iD;
            return entity.Delete();
        }

        public int Delete()
        {
            return this.Delete(null);
        }

        //---------------------------------------------------------------------------------------------

        public int Delete(SqlTransaction transaction)
        {
            string spName = "[dbo].p_MARKETING_Service_Delete";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@ID", SqlDbType.Int, this._ID);

            if (transaction != null)
                return db.ExecuteNonQuery(dbCommand, transaction);
            else
                return db.ExecuteNonQuery(dbCommand);
        }

        #endregion
    }
}